package cn.doourbest.mybatis.generate;

import org.junit.Test;
import org.springframework.boot.test.context.SpringBootTest;
import java.util.Arrays;

@SpringBootTest
public class GenerateMybatisNameMainClass {

    @Test
    public void generateName(){
        String ss =
                "d_ff_dd\n";


        Arrays.stream(ss.split(",")).forEach(
                x -> {
                    x = x.replace("\n","");
                    String[] ff = x.split("_");
                    int len = ff.length;

                    StringBuilder sb = new StringBuilder();
                    for(int i = 0; i <= len - 1; i++) {
                        if(i == 0){
                            continue;
                        }
                        String s = ff[i];
                        sb.append(s.substring(0,1).toUpperCase());
                        sb.append(s.substring(1));
                    }

                    String stringBuilder = "<table tableName=\"" +
                            x +
                            "\" mapperName=\"" +
                            sb.toString() +
                            "Mapper" +
                            "\" domainObjectName=\"" +
                            sb.toString() +
                            "PO" +
                            "\" enableCountByExample=\"false\" enableUpdateByExample=\"false\" enableDeleteByExample=\"false\" enableSelectByExample=\"false\" selectByExampleQueryId=\"false\" > <property name=\"useActualColumnNames\" value=\"false\"/> " +
                            "<property name=\"rootInterface\" value=\"com.baomidou.mybatisplus.core.mapper.BaseMapper&lt;"+ sb.toString() +
                            "PO" + "&gt;\"/>" +
                            "</table>";
                    System.out.println(stringBuilder);
                }
        );
    }
}
